"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var waterFall_1 = require("./waterFall");
/**
 * 增加了偏移量的设定,可以调整top,right,bottom,left的数值
 * @param {number} containerWidth 布局的宽度
 * @param {number} elWidth 单个元素的宽度
 * @param {object} lists 要排列的元素的对象
 * @param {number} column 要摆放的列数
 */
var WaterFallOffset = /** @class */ (function (_super) {
    __extends(WaterFallOffset, _super);
    function WaterFallOffset(containerWidth, elWidth, lists, column, offset) {
        var _this = _super.call(this, containerWidth, elWidth, lists, column) || this;
        _this.setOffset(offset);
        return _this;
    }
    WaterFallOffset.prototype.setOffset = function (offset) {
        offset = offset === undefined ? { offsetTop: 0, offsetRight: 0, offsetBottom: 0, offsetLeft: 0 } : offset;
        var offsetTop = offset.offsetTop, offsetRight = offset.offsetRight, offsetBottom = offset.offsetBottom, offsetLeft = offset.offsetLeft;
        this.offsetTop = offsetTop;
        this.offsetRight = offsetRight;
        this.offsetBottom = offsetBottom;
        this.offsetLeft = offsetLeft;
    };
    /**
     * 计算各个元素的位置
     * @return {IList[]} value 以计算的元素
     */
    WaterFallOffset.prototype.position = function (value) {
        if (value === void 0) { value = this._lists; }
        this._width = this._elWidth + waterFall_1.WaterFall.widthFill(this._containerWidth, this._elWidth, this._column);
        // const offsetLeft = this.offsetLeft/2;
        var column = this._column;
        this.add(value);
        if (!value[0].isPosition) {
            value[0].top = value[0].left = 0;
            value[0].width = this._width;
            value[0].isPosition = true;
        }
        for (var i = 1, length_1 = value.length; i < length_1; i++) {
            if (i < column && !value[i].isPosition) {
                value[i].top = 0;
                value[i].left = this._width * (i % column);
                value[i].width = this._width;
                value[i].isPosition = true;
            }
            else if (!value[i].isPosition) {
                value[i].top = (value[i - column].top + value[i - column].el.clientHeight);
                value[i].left = this._width * (i % column);
                value[i].width = this._width;
                value[i].isPosition = true;
            }
        }
        return value;
    };
    return WaterFallOffset;
}(waterFall_1.WaterFall));
exports.WaterFallOffset = WaterFallOffset;
